package com.fintech.third.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fintech.common.constant.TableName;
import com.fintech.common.dao.ZxDataDao;
import com.fintech.common.service.BaseServiceImpl;
import com.fintech.common.util.PropertiesUtils;
import com.fintech.third.constant.ThirdMethodConstants;
import com.fintech.third.constant.ZxDataProvider;
import com.fintech.third.dao.intbank.IntBankBanruDetailMapper;
import com.fintech.third.dao.intbank.IntBankBasicMapper;
import com.fintech.third.dao.intbank.IntBankCreditCardMapper;
import com.fintech.third.dao.intbank.IntBankCreditPaymentRecordsMapper;
import com.fintech.third.dao.intbank.IntBankCredittipsMapper;
import com.fintech.third.dao.intbank.IntBankDwellmessageMapper;
import com.fintech.third.dao.intbank.IntBankEndowmentInsuranceMapper;
import com.fintech.third.dao.intbank.IntBankGuaranteeCountMapper;
import com.fintech.third.dao.intbank.IntBankNotCredittipsMapper;
import com.fintech.third.dao.intbank.IntBankNotPinshouseholdsMapper;
import com.fintech.third.dao.intbank.IntBankNotQuasiCreditMapper;
import com.fintech.third.dao.intbank.IntBankPositionmesageMapper;
import com.fintech.third.dao.intbank.IntBankQueryDetailMapper;
import com.fintech.third.dao.intbank.IntBankQuerySummaryMapper;
import com.fintech.third.dao.intbank.IntBankStandardCreditCardMapper;
import com.fintech.third.dao.moxie.MoXieDataInfoMapper;
import com.fintech.third.model.InquiryDetailsDTO;
import com.fintech.third.model.ZxDataReqDTO;
import com.fintech.third.model.ZxDataRespDTO;
import com.fintech.third.model.intbank.IntBankBanruDetail;
import com.fintech.third.model.intbank.IntBankBasic;
import com.fintech.third.model.intbank.IntBankCreditCard;
import com.fintech.third.model.intbank.IntBankCreditPaymentRecords;
import com.fintech.third.model.intbank.IntBankCredittips;
import com.fintech.third.model.intbank.IntBankDwellmessage;
import com.fintech.third.model.intbank.IntBankEndowmentInsurance;
import com.fintech.third.model.intbank.IntBankGuaranteeCount;
import com.fintech.third.model.intbank.IntBankNotCredittips;
import com.fintech.third.model.intbank.IntBankNotPinshouseholds;
import com.fintech.third.model.intbank.IntBankNotQuasiCredit;
import com.fintech.third.model.intbank.IntBankPositionmesage;
import com.fintech.third.model.intbank.IntBankQueryDetail;
import com.fintech.third.model.intbank.IntBankQuerySummary;
import com.fintech.third.model.intbank.IntBankStandardCreditCard;
import com.fintech.third.model.moxie.dataprovide.IntMxAccountBaseInfo;
import com.fintech.third.model.moxie.dataprovide.IntMxActiveDegreeDetail;
import com.fintech.third.model.moxie.dataprovide.IntMxActiveDegress;
import com.fintech.third.model.moxie.dataprovide.IntMxBasicInfoCheckItems;
import com.fintech.third.model.moxie.dataprovide.IntMxCallAnalysis;
import com.fintech.third.model.moxie.dataprovide.IntMxCallFamilyDetail;
import com.fintech.third.model.moxie.dataprovide.IntMxCallThirdPartyDetail;
import com.fintech.third.model.moxie.dataprovide.IntMxCallTimeDetail;
import com.fintech.third.model.moxie.dataprovide.IntMxConsumptionAnalysis;
import com.fintech.third.model.moxie.dataprovide.IntMxConsumptionDetail;
import com.fintech.third.model.moxie.dataprovide.IntMxDataSource;
import com.fintech.third.model.moxie.dataprovide.IntMxPackageInfo;
import com.fintech.third.model.moxie.dataprovide.IntMxRiskAnalysis;
import com.fintech.third.model.moxie.dataprovide.IntMxUserBasicInfo;
import com.fintech.third.model.moxie.dataprovide.IntMxUserInfo;
import com.fintech.third.model.shzx.EdcZxPersonalAddrInfo;
import com.fintech.third.model.shzx.EdcZxPersonalBasicInfo;
import com.fintech.third.model.shzx.EdcZxPersonalFirstOneRelationInfo;
import com.fintech.third.model.shzx.EdcZxPersonalGuaranteeInfo;
import com.fintech.third.model.shzx.EdcZxPersonalLoanApplyInfo;
import com.fintech.third.model.shzx.EdcZxPersonalLoanOrderDetailsInfo;
import com.fintech.third.model.shzx.EdcZxPersonalLoanOrderInfo;
import com.fintech.third.model.shzx.EdcZxPersonalPromptInfo;
import com.fintech.third.model.shzx.EdcZxPersonalQueryInfo;
import com.fintech.third.model.shzx.EdcZxPersonalRecordsInfo;
import com.fintech.third.model.shzx.EdcZxPersonalSpecialOrderInfo;
import com.fintech.third.model.shzx.EdcZxPersonalSpouseInfo;
import com.fintech.third.model.shzx.EdcZxPersonalUnitInfo;
import com.marvels.common.utils.MarvelsLogUtil;

/**
 * 征信数据查询服务SERVICE
 * 
 * @author tux
 *
 */
@Service("zxDataService")
public class ZxDataServiceImpl extends BaseServiceImpl implements ZxDataService {
	@Autowired
	private IntBankStandardCreditCardMapper intBankStandardCreditCardMapper;
	@Autowired
	private IntBankEndowmentInsuranceMapper intBankEndowmentInsuranceMapper;
	@Autowired
	private IntBankGuaranteeCountMapper intBankGuaranteeCountMapper;
	@Autowired
	private IntBankNotQuasiCreditMapper intBankNotQuasiCreditMapper;
	@Autowired
	private IntBankNotCredittipsMapper intBankNotCredittipsMapper;
	@Autowired
	private IntBankNotPinshouseholdsMapper intBankNotPinshouseholdsMapper;
	@Autowired
	private IntBankCreditPaymentRecordsMapper intBankCreditPaymentRecordsMapper;
	@Autowired
	private IntBankCreditCardMapper intBankCreditCardMapper;
	@Autowired
	private IntBankBanruDetailMapper intBankBanruDetailMapper;
	@Autowired
	private IntBankQuerySummaryMapper intBankQuerySummaryMapper;
	@Autowired
	private IntBankBasicMapper intBankBasicMapper;
	@Autowired
	private IntBankCredittipsMapper intBankCredittipsMapper;
	@Autowired
	private IntBankPositionmesageMapper intBankPositionmesageMapper;
	@Autowired
	private IntBankQueryDetailMapper intBankQueryDetailMapper;
	@Autowired
	private IntBankDwellmessageMapper intBankDwellmessageMapper;

	@Autowired
	private ZxDataDao zxDataDao;
	@Autowired 
	MoXieDataInfoMapper moXieDataInfoMapper;
	
	@Override
	public ZxDataRespDTO queryZxDataList(ZxDataReqDTO reqDto, String dataProvider) {
		MarvelsLogUtil.getInstance().info("======ZxDataServiceImpl.queryZxDataList begin====== dataProvider=" + dataProvider + " reqDto="
				+ reqDto);
		List<Map> list = null;
		ZxDataRespDTO respDto = new ZxDataRespDTO();
		String loanId = reqDto.getLoanId();
		String custCardNo = reqDto.getCustCardNo();
		String mobileNo = reqDto.getMobileNo();
		/**
		 * 查询各渠道的征信数据，每个渠道最多展示limit条数据，包含成功和失败的。<BR>
		 * 默认10条记录
		 */
		int limit = 10;
		try {
			limit = Integer.parseInt(PropertiesUtils.getString("zx.show.limit"));
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("获取征信查询条数异常，默认展示" + limit + "条", e);
		}
		MarvelsLogUtil.getInstance().info("======limit:" + limit);

		// 魔蝎列表
		if (ZxDataProvider.MOXIE.getCode().equals(dataProvider)) {
			list = zxDataDao.getQueryDataListByMobileNo(TableName.MX.getCode(), ThirdMethodConstants.MX0001, mobileNo,
					limit);
			respDto.setData(list);
			return respDto;
		}
		// 鹏元数据列表
		if (ZxDataProvider.PENGYUAN.getCode().equals(dataProvider)) {
			list = zxDataDao.getQueryDataListByIdNo(TableName.PYZX.getCode(), ThirdMethodConstants.PY0001, custCardNo,
					limit);
			respDto.setData(list);
			return respDto;
		}
		// 汇法网数据列表
		if (ZxDataProvider.HF.getCode().equals(dataProvider)) {
			list = zxDataDao.getQueryDataListByIdNo(TableName.HF.getCode(), ThirdMethodConstants.HF0000, custCardNo,
					limit);
			respDto.setData(list);
			return respDto;
		}
		// 上海资信数据列表
		if (ZxDataProvider.SHZX.getCode().equals(dataProvider)) {
			list = zxDataDao.getQueryDataListByIdNo(TableName.SHZX.getCode(), ThirdMethodConstants.SHANGHAIZX001,
					custCardNo, limit);
			respDto.setData(list);
			return respDto;
		}
		// 51公积金
		if (ZxDataProvider.GJJ51.getCode().equals(dataProvider)) {
			list = zxDataDao.getQueryDataListByIdNo(TableName.WY51.getCode(),
					ThirdMethodConstants.GJJ_51_GET_ORDER_DATA_003, custCardNo, limit);
			respDto.setData(list);
			return respDto;
		}
		// 51社保
		if (ZxDataProvider.SB51.getCode().equals(dataProvider)) {
			list = zxDataDao.getQueryDataListByIdNo(TableName.WY51.getCode(),
					ThirdMethodConstants.SB_51_GET_ORDER_DATA_003, custCardNo, limit);
			respDto.setData(list);
			return respDto;
		}
		// 卡牛普通数据列表
		if (ZxDataProvider.KANIU.getCode().equals(dataProvider)) {
			list = zxDataDao.getQueryDataListByIdNo(TableName.KANIU.getCode(), ThirdMethodConstants.KANIU002,
					custCardNo, limit);
			respDto.setData(list);
			return respDto;
		}
		// 云房贷卡牛数据
		if (ZxDataProvider.YFD_KANIU.getCode().equals(dataProvider)) {
			list = zxDataDao.getQueryDataListByIdNo(TableName.KANIU.getCode(), ThirdMethodConstants.KANIU002,
					custCardNo, limit);
			respDto.setData(list);
			return respDto;
		}
		// 卡牛产品魔蝎数据
		if (ZxDataProvider.KANIU_MX.getCode().equals(dataProvider)) {
			List<Map> listed = zxDataDao.selectEdcKnCreditCardInfoByReqNo(loanId);
			respDto.setData(listed);
			return respDto;
		}
		// 人行报告数据
		if (ZxDataProvider.RHBG.getCode().equals(dataProvider)) {
			list = zxDataDao.getQueryRHDataList(loanId);
			respDto.setData(list);
			return respDto;
		}
		return respDto;

	}

	@Override
	public ZxDataRespDTO queryZxDataDetail(ZxDataReqDTO reqDto, String dataProvider) {
		MarvelsLogUtil.getInstance().info("======ZxDataServiceImpl.queryZxDataDetail begin====== dataProvider=" + dataProvider + " reqDto="
				+ reqDto);
		ZxDataRespDTO respDto = new ZxDataRespDTO();
		String loanId = reqDto.getLoanId();
		String reqNo = reqDto.getReqNo();
		InquiryDetailsDTO inq = new InquiryDetailsDTO();
		// 魔蝎详情数据
		if (ZxDataProvider.MOXIE.getCode().equals(dataProvider)) {
			String dataType = "近三个月";
			String dataTypeTwo = "近六个月";
			/*
			 * 征信页面显示的魔蝎数据比较特殊，是由三个魔蝎接口数据组成。
			 * DATA_QUERY表的中REQ_NO为结果表中的REQ_NO+_+接口编码，如MX2309842034823042_Mx0001
			 * 这里的reqNo为DATA_QUERY表的中REQ_NO
			 */
			String rstReqNo = StringUtils.substringBefore(reqNo, "_" + ThirdMethodConstants.MX0001.substring(0, 4));
			inq = selectMXInfo(rstReqNo, dataType, dataTypeTwo, loanId);
			respDto.setData(inq);
			MarvelsLogUtil.getInstance().info("respDto：" + respDto);
			return respDto;
		}
		// 鹏元征信数据
		if (ZxDataProvider.PENGYUAN.getCode().equals(dataProvider)) {
			Map<String, Object> returnMap = selectPYInfo(reqNo);
			respDto.setData(returnMap);
			return respDto;
		}
		
		// 上海资信详情数据
		if (ZxDataProvider.SHZX.getCode().equals(dataProvider)) {
			Map map = selectSHZXInfo(reqNo);
			respDto.setData(map);
			return respDto;
		}
		// 51公积金明细
		if (ZxDataProvider.GJJ51.getCode().equals(dataProvider)) {
			Map<String, Object> datas = selectFundDetail(reqNo);
			respDto.setData(datas);
			return respDto;
		}
		// 51社保明细
		if (ZxDataProvider.SB51.getCode().equals(dataProvider)) {
			Map sbMap = selectSBInfo(reqNo);
			respDto.setData(sbMap);
			return respDto;
		}
		
		
		// 卡牛魔蝎数据
		if (ZxDataProvider.KANIU_MX.getCode().equals(dataProvider)) {// 卡牛喜刷刷魔蝎数
			Map datas = zxDataDao.selectEdcKnCreditCardInfoBy(reqNo);
			respDto.setData(datas);
			return respDto;
		}
		// 人行数据
		if (ZxDataProvider.RHBG.getCode().equals(dataProvider)) {
			Map datas = selectRHInfo(reqNo);
			respDto.setData(datas);
			return respDto;
		}
		return respDto;
	}

	private Map selectRHInfo(String reqNo){
		Map map = new HashMap();
		List<IntBankBasic>	intBankBasic = intBankBasicMapper.intBankBasic(reqNo);//基本信息
		List<IntBankDwellmessage> intBankDwellmessage = intBankDwellmessageMapper.intBankDwellmessage(reqNo);//居住信息
		List<IntBankPositionmesage> intBankPositionmesage = intBankPositionmesageMapper.intBankPositionmesage(reqNo);//职业信息
		List<IntBankCredittips> intBankCredittips = intBankCredittipsMapper.intBankCredittips(reqNo);//信息1
		List<IntBankNotCredittips> intBankNotCredittips = intBankNotCredittipsMapper.intBankNotCredittips(reqNo);//信息2
		List<IntBankNotPinshouseholds> intBankNotPinshouseholds = intBankNotPinshouseholdsMapper.intBankNotPinshouseholds(reqNo);//信息3
		List<IntBankNotQuasiCredit> intBankNotQuasiCredit = intBankNotQuasiCreditMapper.intBankNotQuasiCredit(reqNo);//信息4
		List<IntBankGuaranteeCount> intBankGuaranteeCount= intBankGuaranteeCountMapper.intBankGuaranteeCount(reqNo);//信息5
		List<IntBankCreditPaymentRecords> intBankCreditPaymentNJQRecords = intBankCreditPaymentRecordsMapper.intBankCreditPaymentNJQRecords(reqNo);//未结清贷款
		List<IntBankCreditPaymentRecords> intBankCreditPaymentJQRecords = intBankCreditPaymentRecordsMapper.intBankCreditPaymentJQRecords(reqNo);//结清贷款
		List<IntBankCreditCard> intBankCreditCardNXh = intBankCreditCardMapper.intBankCreditCardNXh(reqNo);//未消户贷记卡
		List<IntBankCreditCard> intBankCreditCardXh = intBankCreditCardMapper.intBankCreditCardXh(reqNo);//消户贷记卡
		List<IntBankStandardCreditCard> intBankStandardCreditCards = intBankStandardCreditCardMapper.intBankStandardCreditCard(reqNo);//准贷记卡
		List<IntBankEndowmentInsurance> intBankEndowmentInsurance = intBankEndowmentInsuranceMapper.intBankEndowmentInsurance(reqNo);//公共信息明细
		List<IntBankQuerySummary> intBankQuerySummary = intBankQuerySummaryMapper.intBankQuerySummary(reqNo);//查询记录汇总
		List<IntBankQueryDetail> intBankQueryDetail = intBankQueryDetailMapper.intBankQueryDetail(reqNo);//查询记录
		List<IntBankBanruDetail> intBankBanruDetail = intBankBanruDetailMapper.intBankBanruDetail(reqNo);//个人查询记录
		if (CollectionUtils.isNotEmpty(intBankBasic)) {
			map.put("intBankBasic", intBankBasic.get(0));			
		}
		map.put("dwellmessageList", intBankDwellmessage);
		map.put("intBankPositionmesageList", intBankPositionmesage);
		if (CollectionUtils.isNotEmpty(intBankCredittips)) {
			map.put("intBankCredittipsForm", intBankCredittips.get(0));			
		}
		if (CollectionUtils.isNotEmpty(intBankNotCredittips)) {
			map.put("intBankNotCredittipsForm", intBankNotCredittips.get(0));			
		}
		if (CollectionUtils.isNotEmpty(intBankNotPinshouseholds)) {
			map.put("intBankNotPinshouseholdsForm", intBankNotPinshouseholds.get(0));
		}
		if (CollectionUtils.isNotEmpty(intBankNotQuasiCredit)) {
			map.put("intBankNotQuasiCreditForm", intBankNotQuasiCredit.get(0));
		}
		if (CollectionUtils.isNotEmpty(intBankGuaranteeCount)) {
			map.put("intBankGuaranteeCountForm", intBankGuaranteeCount.get(0));
		}
		map.put("intBankCreditPaymentJQList", intBankCreditPaymentJQRecords);
		map.put("intBankCreditPaymentNJQList", intBankCreditPaymentNJQRecords);
		map.put("intBankCreditCardXhRecordList", intBankCreditCardXh);
		map.put("intBankCreditCardNXhRecordList", intBankCreditCardNXh);		
		map.put("intBankStandardCreditCardsList", intBankStandardCreditCards);
		if (CollectionUtils.isNotEmpty(intBankEndowmentInsurance)) {
			map.put("intBankEndowmentInsuranceForm", intBankEndowmentInsurance.get(0));
		}
		map.put("intBankQuerySummaryList", intBankQuerySummary);
		map.put("intBankQueryDetailList", intBankQueryDetail);
		map.put("intBankBanruDetailList", intBankBanruDetail);
		return map;
	}
	
	private Map selectSHZXInfo(String reqNo){
		Map map = new HashMap();
		//个人基本信息
		EdcZxPersonalBasicInfo edcZxPersonalBasicInfo=zxDataDao.queryEdcZxPersonalBasicInfo(reqNo);
		List<EdcZxPersonalAddrInfo> addrInfoList=zxDataDao.queryPersonalAddr(reqNo);//地址信息
		List<EdcZxPersonalUnitInfo> UnitInfoList=zxDataDao.queryPersonalUnitInfo(reqNo);//工作信息
		List<EdcZxPersonalFirstOneRelationInfo> firstOneRelationInfoList=zxDataDao.queryPersonalFirstOneRelationInfo(reqNo);//联系人信息
		List<EdcZxPersonalFirstOneRelationInfo> first = new ArrayList<EdcZxPersonalFirstOneRelationInfo>();
		List<EdcZxPersonalFirstOneRelationInfo> two = new ArrayList<EdcZxPersonalFirstOneRelationInfo>();
		for (EdcZxPersonalFirstOneRelationInfo e : firstOneRelationInfoList) {
			if("".equals(e.getType())||"1".equals(e.getType())){
				first.add(e);//第一联系人
			}else{
				two.add(e);//第二联系人
			}
		}
		//个人信息原因查询
		EdcZxPersonalQueryInfo edcZxPersonalQueryInfo=zxDataDao.queryPersonalQueryInfo(reqNo);
		//配偶信息
		EdcZxPersonalSpouseInfo edcZxPersonalSpouseInfo=zxDataDao.queryPersonalSpouseInfo(reqNo);
		//贷款申请信息
		List<EdcZxPersonalLoanApplyInfo> loanApplyList=zxDataDao.queryPersonalLoanApplyInfo(reqNo);
		//个人交易概要信息
		EdcZxPersonalLoanOrderInfo loanOrder=zxDataDao.queryPersonalLoanOrderInfo(reqNo);
		//个人交易详情信息
		List<EdcZxPersonalLoanOrderDetailsInfo> orderDetailList=zxDataDao.queryPersonalLoanOrderDetailsInfo(reqNo);
		//个人为他人担保信息
		List<EdcZxPersonalGuaranteeInfo> guaramList=zxDataDao.queryPersonalGuaranteeInfo(reqNo);
		//特殊交易信息
		List<EdcZxPersonalSpecialOrderInfo> orderList=zxDataDao.queryPersonalSpecialOrderInfo(reqNo);
		//查询记录信息
		List<EdcZxPersonalRecordsInfo> recoredsList=zxDataDao.queryPersonalRecordsInfo(reqNo);
		//资信提示信息
		List<EdcZxPersonalPromptInfo> promptList=zxDataDao.queryPersonalPromptInfo(reqNo);
		map.put("EdcZxPersonalQueryInfo", edcZxPersonalQueryInfo);
		map.put("EdcZxPersonalBasicInfo", edcZxPersonalBasicInfo);
		map.put("AddrInfoList", addrInfoList);		
		map.put("UnitInfoList", UnitInfoList);		
		map.put("EdcZxPersonalSpouseInfo", edcZxPersonalSpouseInfo);
		map.put("FirstOneRelationInfoList", first);
		map.put("FirstTwoRelationInfoList", two);
		map.put("LoanApplyInfoList", loanApplyList);
		map.put("EdcZxPersonalLoanOrderInfo", loanOrder);
		map.put("LoanOrderDetailsInfoList", orderDetailList);
		map.put("GuaranteeInfoList", guaramList);
		map.put("SpecialOrderInfoList", orderList);
		map.put("RecordsInfoList", recoredsList);
		map.put("PromptInfoList", promptList);
		return map;
	}
	private Map selectPYInfo(String reqNo){
		Map<String, Object> returnMap = new HashMap<String, Object>();
		/*List<IntPyPersonShareholderreport> intPyPersonShareholderreport=edcPyObtainSmallPersonalCreditMapper.intPyPersonShareholderreport(reqNo);
		List<IntPyPersonArtificialnationalInfo> intPyPersonArtificialnationalInfo=edcPyObtainSmallPersonalCreditMapper.intPyPersonArtificialnationalInfo(reqNo);
		List<IntPyPersonTopmanagerinfo> intPyPersonTopmanagerinfo=edcPyObtainSmallPersonalCreditMapper.intPyPersonTopmanagerinfo(reqNo);
		returnMap.put("intPyPersonShareholderreport", intPyPersonShareholderreport);
		returnMap.put("intPyPersonArtificialnationalInfo", intPyPersonArtificialnationalInfo);
		returnMap.put("intPyPersonTopmanagerinfo", intPyPersonTopmanagerinfo);*/
		return returnMap;
	}
	private InquiryDetailsDTO selectMXInfo(String reqNo, String dataType, String dataTypeTwo,String loanId){
		InquiryDetailsDTO inq = new InquiryDetailsDTO();
		inq.setIntMxDataUsageDetails(moXieDataInfoMapper.searchDataUsageDetails(reqNo));
		inq.setIntMxSmsDetails(moXieDataInfoMapper.searchSmsDetails(reqNo));
		List<IntMxUserInfo> intMxUserInfo = moXieDataInfoMapper.searchMxUserInfo(reqNo);
		if (CollectionUtils.isNotEmpty(intMxUserInfo)) {
			inq.setIntMxUserInfo(intMxUserInfo.get(0));				
		}
		inq.setIntMxBillRecord(moXieDataInfoMapper.searchMxBillRecord(reqNo));
		inq.setIntMxBillsMonth(moXieDataInfoMapper.searchMxBillsMonth(reqNo));
		inq.setIntMxCallContactDetail(moXieDataInfoMapper.searchCallContactDetail(reqNo));
		inq.setIntMxCallDetails(moXieDataInfoMapper.searchMxCallDetails(reqNo));
		inq.setCallDurationDetail3m(moXieDataInfoMapper.searchCallDurationDetail(reqNo, dataType));
		inq.setCallDurationDetail6m(moXieDataInfoMapper.searchCallDurationDetail(reqNo, dataTypeTwo));
		inq.setCallLocationDetail3mList(moXieDataInfoMapper.searchCallLocationDetail(reqNo, dataType));
		inq.setCallLocationDetail6mList(moXieDataInfoMapper.searchCallLocationDetail(reqNo, dataTypeTwo));
		inq.setIntMxCallLocationTop3m(moXieDataInfoMapper.searchCallLocationTop3(reqNo, dataType));
		inq.setIntMxCallLocationTop6m(moXieDataInfoMapper.searchCallLocationTop3(reqNo,dataTypeTwo));
		inq.setIntMxCallNumTop3m(moXieDataInfoMapper.searchCallNumTop3(reqNo, dataType));
		inq.setIntMxCallNumTop6m(moXieDataInfoMapper.searchCallNumTop3(reqNo, dataTypeTwo));
		inq.setIntMxLoanInfo(moXieDataInfoMapper.searchMxLoanInfo(reqNo));
		inq.setIntMxLoanRepayRecord(moXieDataInfoMapper.searchLoanRepayRecord(reqNo));
		inq.setIntMxPackageItems(moXieDataInfoMapper.searchPackageItems(reqNo));
		inq.setIntMxRechargeItems(moXieDataInfoMapper.searchFanLiOperatorPaymentInfo(loanId));
		inq.setRiskCheckItemList(moXieDataInfoMapper.searchRiskCheckItem(reqNo));
		inq.setIntMxCallLocal6m(moXieDataInfoMapper.searchCallLocal6m(reqNo));
		inq.setIntMxCallMobile6m(moXieDataInfoMapper.searchCallMobile6m(reqNo));
		List<IntMxAccountBaseInfo> intMxAccountBase =moXieDataInfoMapper.searchAccountBaseInfo(reqNo);
		if (CollectionUtils.isNotEmpty(intMxAccountBase)) {
			inq.setIntMxAccountBaseInfo(intMxAccountBase.get(0));
		}
		List<IntMxActiveDegreeDetail> intMxActiveDegree =moXieDataInfoMapper.searchActiveDegreeDetail(reqNo);
		if (CollectionUtils.isNotEmpty(intMxActiveDegree)) {
			inq.setIntMxActiveDegreeDetail(intMxActiveDegree.get(0));
		}
		List<IntMxActiveDegress> intMxActive =moXieDataInfoMapper.searchActiveDegress(reqNo);
		if (CollectionUtils.isNotEmpty(intMxActive)) {
			inq.setIntMxActiveDegress(intMxActive.get(0));
		}
		List<IntMxBasicInfoCheckItems> intMxBasicInfoCheck =moXieDataInfoMapper.searchBasicInfoCheckItems(reqNo); 
		if (CollectionUtils.isNotEmpty(intMxBasicInfoCheck)) {
			inq.setIntMxBasicInfoCheckItems(intMxBasicInfoCheck.get(0));
		}
		List<IntMxCallAnalysis> intMxCallAna =moXieDataInfoMapper.searchMxCallAnalysis(reqNo);
		if (CollectionUtils.isNotEmpty(intMxCallAna)) {
			inq.setIntMxCallAnalysis(intMxCallAna.get(0));
		}
		List<IntMxCallFamilyDetail> intMxCallFamily =moXieDataInfoMapper.searchCallFamilyDetail(reqNo);
		if (CollectionUtils.isNotEmpty(intMxCallFamily)) {
			inq.setIntMxCallFamilyDetail(intMxCallFamily.get(0));
		}
		List<IntMxCallThirdPartyDetail> intMxCallThirdParty =moXieDataInfoMapper.searchCallThirdPartyDetail(reqNo);
		if (CollectionUtils.isNotEmpty(intMxCallThirdParty)) {
			inq.setIntMxCallThirdPartyDetail(intMxCallThirdParty.get(0));
		}
		List<IntMxCallTimeDetail> intMxCallTime =moXieDataInfoMapper.searchCallTimeDetail(reqNo);
		if (CollectionUtils.isNotEmpty(intMxCallTime)) {
			inq.setIntMxCallTimeDetail(intMxCallTime.get(0));
		}
		List<IntMxConsumptionAnalysis> intMxConsumption =moXieDataInfoMapper.searchConsumptionAnalysis(reqNo);
		if (CollectionUtils.isNotEmpty(intMxConsumption)) {
			inq.setIntMxConsumptionAnalysis(intMxConsumption.get(0));
		}
		List<IntMxConsumptionDetail> intMxConsumptionDe =moXieDataInfoMapper.searchConsumptionDetail(reqNo);
		if (CollectionUtils.isNotEmpty(intMxConsumptionDe)) {
			inq.setIntMxConsumptionDetail(intMxConsumptionDe.get(0));
		}
		List<IntMxDataSource> intMxDataSource =moXieDataInfoMapper.searchMxDataSource(reqNo);
		if (CollectionUtils.isNotEmpty(intMxDataSource)) {
			inq.setIntMxDataSource(intMxDataSource.get(0));
		} 
		List<IntMxPackageInfo> intMxPackageInfo = moXieDataInfoMapper.searchPackageInfo(reqNo);
		if (CollectionUtils.isNotEmpty(intMxPackageInfo)) {
			inq.setIntMxPackageInfo(intMxPackageInfo.get(0));
		}
		List<IntMxRiskAnalysis> intMxRiskAnalysis = moXieDataInfoMapper.searchRiskAnalysis(reqNo);
		if (CollectionUtils.isNotEmpty(intMxRiskAnalysis)) {
			inq.setIntMxRiskAnalysis(intMxRiskAnalysis.get(0));
		}
		List<IntMxUserBasicInfo> intMxUserBasicInfo = moXieDataInfoMapper.searchUserBasicInfo(reqNo);
		if (CollectionUtils.isNotEmpty(intMxUserBasicInfo)) {
			inq.setIntMxUserBasicInfo(intMxUserBasicInfo.get(0));
		}
		return inq;
		
	}
	private Map selectSBInfo(String reqNo){
		Map dataMap = new HashMap<>();
		/*Map<String,Object> selectAccount = getSb51DataMapper.selectAccount(reqNo);//社保账户基本信息,所有单个数据
		List<Map<String, Object>> endowmentPay = getSb51DataMapper.selectEndowmentPay(reqNo);// 养老保险缴存记录
		List<Map<String, Object>> endowmentUse = getSb51DataMapper.selectEndowmentUse(reqNo);// 养老保险使用明细
		List<Map<String, Object>> healthPay = getSb51DataMapper.selectHealthPay(reqNo);// 医疗保险缴存记录
		List<Map<String, Object>> healthUse = getSb51DataMapper.selectHealthUse(reqNo);// 医疗保险使用明细
		List<Map<String, Object>> joblessPay = getSb51DataMapper.selectJoblessPay(reqNo);// 失业保险缴存记录
		List<Map<String, Object>> joblessUse = getSb51DataMapper.selectJoblessUse(reqNo);// 失业保险使用明细
		List<Map<String, Object>> birthPay = getSb51DataMapper.selectBirthPay(reqNo);// 生育保险缴存记录
		List<Map<String, Object>> birthUse = getSb51DataMapper.selectBirthUse(reqNo);// 生育保险使用明细
		List<Map<String, Object>> injuryPay = getSb51DataMapper.selectInjuryPay(reqNo);// 工伤保险缴存记录
		List<Map<String, Object>> injuryUse = getSb51DataMapper.selectInjuryUse(reqNo);// 工伤保险使用明细
		dataMap.put("account", selectAccount);
		dataMap.put("injuryPay", injuryPay);
		dataMap.put("injuryUse", injuryUse);
		dataMap.put("birthPay", birthPay);
		dataMap.put("birthUse", birthUse);
		dataMap.put("joblessPay", joblessPay);
		dataMap.put("joblessUse", joblessUse);
		dataMap.put("healthUse", healthUse);
		dataMap.put("healthPay", healthPay);
		dataMap.put("endowmentUse", endowmentUse);
		dataMap.put("endowmentPay", endowmentPay);*/
		return dataMap;
	}
	/**查询房贷明细
	 * @param requestId
	 * @return
	 */
	private Map<String, Object> selectFundDetail(String requestId) {
		Map<String, Object> map = new HashMap();
		List<Map<String,Object>> itemDetail = null;//gjj51DataService.selectItemDetail(requestId);
		List<Map<String,Object>> loanItemDetail = null;//gjj51DataService.selectLoanItemDetail(requestId);
		List<Map<String,Object>> companyData = null;//gjj51DataService.selectCompanyData(requestId);
		Map<String, Object> account = null;//gjj51DataService.selectAccount(requestId);
		map.put("itemDetail", itemDetail);
		map.put("loanItemDetail", loanItemDetail);
		map.put("companyData", companyData);
		map.put("account", account);
		return map;
	}
	
	
	
	
	

}

